<template lang="pug">
  div
    s-table(
      ref="table"
      :column="tableObj.column"
      :filterProps="{items: filterItems}"
      :queryFn="tableObj.getList"
      rowKey="taskId"
      title="任务审核"
      @rowClick="row => tableRowClick(row)"
      )
      template(slot="taskType" slot-scope="text, scope") {{dictFilter(text, 'SCEN_TASK_WAY')}}
      template(slot="taskStas" slot-scope="text, scope") {{dictFilter(text, 'SCEN_TASK_STAS')}}
      s-table(
        ref="infoTable"
        slot="table-right"
        :column="tableInfoObj.column"
        :tableProps="{'row-key': 'taskId'}"
        :queryFn="tableInfoObj.getList"
        :queryPropsParams="{planId: tableInfoObj.id}"
        )
        template(slot="action" slot-scope="text, scope")
          el-link(type="primary" :underline="false" v-if="scope.sbmtStas === '1' && scope.chkStas === '0'") 审核
          el-link(type="primary" :underline="false" v-else) 详情
</template>
<script>
import { STable } from '@/components'
import { taskChkList, psnChkList } from '@/api/remote'
import DistributeModal from '../distribute/DistributeModal'

const column = [
  {
    prop: 'sort',
    label: '序号'
  },
  {
    prop: 'taskStas',
    label: '任务状态',
    align: 'center'
  },
  {
    prop: 'totalCnt',
    label: '总抽查数',
    align: 'center'
  },
  {
    prop: 'sbmtCnt',
    label: '已提交数',
    align: 'center'
  },
  {
    prop: 'chkCnt',
    label: '已审核数',
    align: 'center'
  },
  {
    prop: 'taskDscr',
    label: '任务描述'
  },
  {
    prop: 'medinsName',
    label: '所属医院'
  },
  {
    prop: 'taskType',
    label: '添加方式',
    align: 'center'
  },
  {
    prop: 'crteDate',
    label: '添加日期',
    align: 'center'
  },
  {
    prop: 'beginTime',
    label: '开始时间',
    align: 'center'
  },
  {
    prop: 'endTime',
    label: '结束时间',
    align: 'center'
  },
  {
    prop: 'crterName',
    label: '添加人'
  },
  {
    prop: 'isuName',
    label: '下发人'
  },
  {
    prop: 'bchno',
    label: '批次号',
    align: 'center'
  }
]

const columnInfo = [
  {
    prop: 'sort',
    label: '序号'
  },
  {
    prop: 'chkStas',
    label: '审核状态',
    align: 'center'
  },
  {
    prop: 'sbmtStas',
    label: '提交状态',
    align: 'center'
  },
  {
    prop: 'recogRate',
    label: '相似度',
    align: 'center'
  },
  {
    prop: 'sbmtRemark',
    label: '查房情况'
  },
  {
    prop: 'psnName',
    label: '患者姓名'
  },
  {
    prop: 'certno',
    label: '证件号码',
    align: 'center'
  },
  {
    prop: 'admdvs',
    label: '医保区'
  },
  {
    prop: 'crteDate',
    label: '添加日期',
    align: 'center'
  },
  {
    prop: 'deptName',
    label: '科室'
  },
  {
    prop: 'loc',
    label: '拍摄地点'
  },
  {
    prop: 'sbmtTime',
    label: '提交时间',
    align: 'center'
  },
  {
    prop: 'isuName',
    label: '提交人'
  },
  {
    prop: 'chkTime',
    label: '审核时间',
    align: 'center'
  },
  {
    prop: 'chkerName',
    label: '审核人'
  },
  {
    prop: 'chkerRema',
    label: '审核备注'
  },
  {
    prop: 'action',
    label: '操作',
    width: '80',
    align: 'center'
  }
]

export default {
  name: 'RemoteAddList',
  components: {
    STable,
    DistributeModal
  },
  data () {
    return {
      tableObj: {
        column,
        getList: taskChkList
      },
      tableInfoObj: {
        column: columnInfo,
        getList: null,
        id: ''
      }
    }
  },
  computed: {
    pageName () {
      return this.$route.name
    },
    filterItems () {
      return [
        {
          key: 'medinsId',
          label: '医疗机构',
          type: 'orgselect'
        },
        {
          key: 'admdvs',
          label: '医保区',
          type: 'selectdict',
          dictKey: 'admdvs'
        },
        {
          key: 'Date',
          label: '添加日期',
          type: 'daterange'
        }
      ]
    }
  },
  created () {
  },
  methods: {
    // 刷新表格
    refreshTable (flag = false) {
      this.$refs.table.refresh(flag)
    },
    // 刷新表格
    refreshRightTable (flag = false) {
      this.$refs.infoTable.refresh(flag)
    },
    // 选择审核任务
    tableRowClick (row) {
      this.tableRightObj.id = row.taskId
      this.tableInfoObj.getList = psnChkList
      this.$nextTick(function () {
        this.refreshRightTable(true)
      })
    }
  }
}
</script>
